﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using IBS.ServiceContracts;

namespace IBS.Bll.Authority
{
    public class AdmissionService : IAdmissionService
    {
        public bool UserWithSameNameExists(string login)
        {
           return Membership.FindUsersByName(login).Count > 0;
        }
        public bool UserWithSameEmailExists(string email)
        {
            return Membership.FindUsersByEmail(email).Count > 0;
        }

        public MembershipUser CreateUser(string userName, string password, string email)
        {
            
           return Membership.CreateUser(userName, password, email);
        }

        public void AddUserToRole(string userName, string role)
        {
            Roles.AddUserToRole(userName, role);
        }
        public IList<MembershipUser> GetAll()
        {
            var res = Membership.GetAllUsers();

            return res.Cast<MembershipUser>().ToList();
        }
        public IList<string> GetUserRoles(string userName)
        {
            return Roles.GetRolesForUser(userName);
        }
    }
}
